
package com.example.myapplicationhjw.demo

fun main() {
    val person = Persons("张三", 18)
    person.sayHello()
    person.run()
    person.eat()
    person.stop()
}

interface IPerson {
    // 属性
    var age: Int
    var name: String
    // 方法
    fun sayHello()
    fun run()

    // 默认实现
    fun eat() {
        println("人会吃饭")
    }
}
interface IVehicle {
    fun stop()
}
// 定义类 实现自   IPerson 接口
class Persons(override var name: String, override var age: Int): IPerson, IVehicle {
    override fun sayHello() {
        println("你好，我是$name，我今年${age}岁")
    }
    override fun run() {
        println("$name 会跑")
    }
    override fun eat() {
        println(" $name 会吃饭")
    }

    override fun stop() {
        println("$name 会停")
    }
}